/**
 * Created by chengming on 18/5/27.
 * version 1.0
 */
const BaseJsonAdapter = require('../base/BaseJsonAdapter');
const iconv = require("iconv-lite");
const vm = require('vm');
const request = require('request-promise');
const logger = require('../../conf/logger');
const querystring = require("querystring")
const urlencode = require("urlencode")

/**
 * 北京互金网
 * @type {module.Bjp2p}
 */
module.exports = class WeBankJson extends BaseJsonAdapter{

    async reqJson(){
        let contents = [];
        let url = 'https://www.webank.com/announcement/#/'

        let body = await this.doRequest();
        let decodeBody = iconv.decode(body, this.encoding).toString();
        let data = JSON.parse(decodeBody);
        if ( data ) {
          for (let row of data) {
            let idList = row['page'].replace('.html','')
            idList = idList.split('_')
            console.log(idList)
            contents.push({
              title: row['title'],
              href: url + idList[1] + '/' + idList[2]
            });
          }
        }
        return {data:contents}
    }
}
